﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace Models.Common
{
    public class Result<T>
    {
        /// <summary>
        /// 获取或设置 Ajax操作结果类型
        /// </summary>
        public AjaxResultType Type { get; set; }

        /// <summary>
        /// 获取或设置 消息内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 获取或设置 返回数据
        /// </summary>
        public T Data { get; set; }
        public int TotalRows { get; set; }
    }
    public class Result1<T>
    {
        /// <summary>
        /// 获取或设置 Ajax操作结果类型
        /// </summary>
        public AjaxResultType Type { get; set; }

        /// <summary>
        /// 获取或设置 消息内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 获取或设置 返回数据
        /// </summary>
        public T Data { get; set; }
        public int TotalRows { get; set; }
        /// <summary>
        /// 净利总和
        /// </summary>
        public string jlrSum { get; set; }
        /// <summary>
        /// 毛利总和
        /// </summary>
        public string mlSum { get; set; }
    }

    public class ResultSerial<T1, T2>
    {
        /// <summary>
        /// 获取或设置 Ajax操作结果类型
        /// </summary>
        public AjaxResultType Type { get; set; }

        /// <summary>
        /// 获取或设置 消息内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 获取或设置 返回数据
        /// </summary>
        public T1 Data1 { get; set; }
        public int TotalRows1 { get; set; }

        public T2 Data2 { get; set; }
        public int TotalRows2 { get; set; }
    }

    public enum AjaxResultType
    {
        /// <summary>
        /// 消息结果类型
        /// </summary>
        Info,

        /// <summary>
        /// 成功结果类型
        /// </summary>
        Success,

        /// <summary>
        /// 警告结果类型
        /// </summary>
        Warning,

        /// <summary>
        /// 异常结果类型
        /// </summary>
        Error,
        /// <summary>
        /// 失败
        /// </summary>
        Fail = -1
    }

    public class GridData<T>
    {
        /// <summary>
        /// 获取或设置 行数据
        /// </summary>
        public List<T> rows { get; set; }

        /// <summary>
        /// 获取或设置 数据行数
        /// </summary>
        public int total { get; set; }
    }

    public class ChuKuDanForInsert
    {
        //public string OrderDate { get; set; }
        public string StoreId { get; set; }
        public string BillCode { get; set; }
        public string EtypeId { get; set; }
        //职员ID
        //public string JingShouRenName { get; set; }
        //public string DtypeID { get; set; }
        public string BtypeId { get; set; }
        //结算单位
        //public string WangLaiDanWeiName { get; set; }
        //public string ZhiDanRenID { get; set; }//制单人

        /// <summary>
        /// AtypeId 收款账户ID 2023-02-23 新增
        /// </summary>
        public string AtypeId { get; set; }

        public string KtypeId { get; set; }//仓库ID
        public string Comment { get; set; }//备注
        public string CustomName { get; set; }//客户姓名
        public string CustomTel { get; set; }//客户电话
        /// <summary>
        /// TotalinMoney 收款金额
        /// </summary>
        public decimal TotalinMoney { get; set; } = 0;
        public decimal TotalMoney { get; set; }
        public decimal TotalQty { get; set; }
        public List<GoodModel> Goods { get; set; }

    }
    public class GoodModel
    {
        public string GoodID { get; set; }
        public string Name { get; set; }
        public decimal Price { get; set; }
        public int Number { get; set; }
        public string Serial { get; set; }//序列号
        public string GoodsNumber { get; set; }//批号
        public string IsGift { get; set; }//赠品标识
        public decimal CostPrice { get; set; }//商品成本单价
        public string Comment { get; set; }//摘要
        public string ProduceDate { get; set; }//生产日期

        public string WyPrice { get; set; }//无忧价格
        public string CargoCode { get; set; } = "";
    }

    public class BaseBillIndexModel
    {
        /// <summary>
        /// 单据code
        /// </summary>
        public string Billcode { get; set; }
        /// <summary>
        /// 职员id
        /// </summary>
        public string Eusercode { get; set; }
        /// <summary>
        /// 入库仓库id
        /// </summary>
        public string InKusercode { get; set; }

        /// <summary>
        /// 出库仓库id
        /// </summary>
        public string OutKusercode { get; set; }

        /// <summary>
        /// 明细集合
        /// </summary>

        public List<CommoditiesDetail> CommoditiesDetails { get; set; }

    }
    /// <summary>
    ///  单据表头 ,与数据库对应(所有字段)
    /// </summary>
    public class BaseBillIndexModel1
    {
        #region 期初单据表头 ,与数据库对应
        /// <summary>
        /// 单据日期
        /// </summary>
        public DateTime BillDate;
        /// <summary>
        /// 单据编号
        /// </summary>
        public string BillCode = string.Empty;
        /// <summary>
        /// 单据类型
        /// </summary>
        public int BillType = 0;
        /// <summary>
        /// 备注
        /// </summary>
        public string Comment = string.Empty;
        /// <summary>
        /// 会计科目id
        /// </summary>
        public string AtypeId = string.Empty;
        /// <summary>
        /// 商品id
        /// </summary>
        public string PtypeId = string.Empty;
        /// <summary>
        /// 往来单位id
        /// </summary>
        public string BtypeId = string.Empty;
        /// <summary>
        /// 职员id
        /// </summary>
        public string EtypeId = string.Empty;
        /// <summary>
        /// 仓库id
        /// </summary>
        public string KtypeId = string.Empty;
        /// <summary>
        /// 仓库2id
        /// </summary>
        public string KtypeId2 = string.Empty;
        /// <summary>
        /// 是否过账标识 't','f'
        /// </summary>
        public char IfCheck = 'f';
        /// <summary>
        /// 制单人
        /// </summary>
        public string Checke = string.Empty;
        /// <summary>
        /// 单据金额
        /// </summary>
        public decimal TotalMoney = 0m;
        /// <summary>
        /// 收款金额
        /// </summary>
        public decimal TotalInMoney = 0m;
        /// <summary>
        /// 单据数量
        /// </summary>
        public decimal TotalQty = 0m;

        /// <summary>
        /// 税率
        /// </summary>
        public decimal Tax = 0m;

        /// <summary>
        /// 会计期间
        /// </summary>
        public int szPeriod = 1;
        /// <summary>
        /// 说明
        /// </summary>
        public string Explain = string.Empty;
        /// <summary>
        /// 红冲标识
        /// </summary>
        public bool RedWord = false;
        /// <summary>
        /// 草稿标识
        /// </summary>
        public bool Draft = true;
        /// <summary>
        /// 订单ID
        /// </summary>
        public long OrderId = 0;

        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// 运单号
        /// </summary>
        public string WayBillCode = string.Empty;
        /// <summary>
        /// 物件数量
        /// </summary>
        public string GoodsNumber = string.Empty;
        /// <summary>
        /// 包装方式
        /// </summary>
        public string PackWay = string.Empty;
        /// <summary>
        /// 电话 这个应该是货运公司
        /// </summary>
        public string Tel = string.Empty;
        /// <summary>
        /// 优惠金额
        /// </summary>
        public decimal PreferenceMoney = 0m;
        /// <summary>
        /// 收付款日期
        /// </summary>
        public int AlertDay = 0;

        public string Assessor = string.Empty;



        /// <summary>
        /// 按单结算金额
        /// </summary>
        public decimal CompleteTotal = 0m;
        /// <summary>
        /// 
        /// </summary>
        public decimal Id = 0m;
        /// <summary>
        /// 是否停止收款
        /// </summary>
        public char IfStopMoney = ' ';

        /// <summary>
        /// 部门id
        /// </summary>
        public string DTypeId = string.Empty;
        /// <summary>
        /// 积分
        /// </summary>
        public int Jf = 0;
        /// <summary>
        /// vip卡id
        /// </summary>
        public int VipCardId = -1;
        /// <summary>
        /// 充值前金额
        /// </summary>
        public decimal VipCZMoney = 0m;
        /// <summary>
        /// 结算方式
        /// </summary>
        public char JsStyle = ' ';
        /// <summary>
        /// 结算状态
        /// </summary>
        public char JsState = ' ';
        /// <summary>
        /// 维修仓库
        /// </summary>
        public string KTypeId3 = string.Empty;
        /// <summary>
        /// 联系人
        /// </summary>
        public string LinkMan = string.Empty;
        /// <summary>
        /// 联系电话
        /// </summary>
        public string LinkTel = string.Empty;
        /// <summary>
        /// 联系地址
        /// </summary>
        public string LinkAddr = string.Empty;
        /// <summary>
        /// 维修人id
        /// </summary>
        public string WxManId = string.Empty;
        /// <summary>
        /// 接件单id
        /// </summary>
        public int JieJianBillNumberId = -1;
        /// <summary>
        /// 接件单明细id
        /// </summary>
        public int JieJianId = -1;
        /// <summary>
        /// 接件状态
        /// </summary>
        public int JieJianState = 0;
        /// <summary>
        /// 报修单id
        /// </summary>
        public int BaoXiuBillNumberID = -1;
        /// <summary>
        /// 报修单明细id
        /// </summary>
        public int BaoXiuID = -1;
        /// <summary>
        /// 会员卡有效期
        /// </summary>
        public DateTime BuyDate = DateTime.MinValue;
        /// <summary>
        /// 序列号
        /// </summary>
        public string Serial = string.Empty;
        /// <summary>
        /// 充值次数,金额
        /// </summary>
        public decimal WxTotal = 0m;
        /// <summary>
        /// 故障描述
        /// </summary>
        public string ErrDes = string.Empty;
        /// <summary>
        /// 是否隐
        /// </summary>
        public int IfHideJieJian = 0;
        /// <summary>
        /// 是否维修单据
        /// </summary>
        public int IfWX = 0;
        /// <summary>
        /// 是否年结后的单据
        /// </summary>
        public int IfYearBill = 0;
        /// <summary>
        /// 最后修改人
        /// </summary>
        public string Poster = string.Empty;
        /// <summary>
        /// 是后修改时间
        /// </summary>
        public DateTime LastUpdateTime;
        /// <summary>
        /// 分支机构
        /// </summary>
        public string StypeId = string.Empty;
        /// <summary>
        /// 源单id
        /// </summary>
        public decimal FromBillNumberId = 0m;
        /// <summary>
        /// 成本价销售标识
        /// </summary>
        public bool CostSale = false;

        /// <summary>
        /// 是否启用品牌
        /// </summary>
        public int isByBrandarType = 0;

        public int OtherInOutType = -1;
        public int PosBillType = 0;
        public DateTime CheckTime;
        public DateTime PostTime;
        public string UpdateE = string.Empty;
        public int ShareMode = 0;
        public string TransportId = string.Empty;
        public string message = string.Empty;
        public string checkSave = string.Empty;
        /// <summary>
        /// 是否年结后的单据
        /// </summary>
        public int CWCheck = 0;
        /// <summary>
        /// 询价单，报价单成交标志 
        /// 0:未成交 1:成交
        /// </summary>
        public int IfBargainOn = 0;
        /// <summary>
        /// 是否多账户收(付)款
        /// </summary>
        public int IfMulAccount = 0;

        public int IsFreightMoney = 0;
        public string FreightAddr = string.Empty;
        public string FreightPerson = string.Empty;
        public string FreightTel = string.Empty;
        public int IfInvoice = 0;
        public string UF1 = string.Empty;
        public string UF2 = string.Empty;
        public string UF3 = string.Empty;
        public string UF4 = string.Empty;
        public string UF5 = string.Empty;
        /// <summary>
        /// 是否是期初
        /// </summary>
        public bool IsIni = true;
        /// <summary>
        /// 往来科目
        /// </summary>
        public string AtypeId1 = string.Empty;
        /// <summary>
        /// 原币结算金额
        /// </summary>
        public decimal NCompleteTotal = 0m;
        /// <summary>
        /// 
        /// </summary>
        public int ATId = 0;
        /// <summary>
        /// 是否启用货位调整
        /// </summary>
        public bool IfCargo = false;
        /// <summary>
        /// 往来单位
        /// </summary>
        public string DealBtypeId = string.Empty;
        /// <summary>
        /// 外币币种id
        /// </summary>
        public int Cid = 0;
        /// <summary>
        /// 汇率
        /// </summary>
        public decimal Rate = 1m;
        /// <summary>
        /// 原币总金额
        /// </summary>
        public decimal NTotalMoney = 0m;
        /// <summary>
        /// 原币收现金额
        /// </summary>
        public decimal NTotalInMoney = 0m;
        /// <summary>
        /// 原币优惠金额
        /// </summary>
        public decimal NPreferenceMoney = 0m;
        /// <summary>
        /// 原币会员卡充值金额
        /// </summary>
        public decimal NVipCZMoney = 0m;
        /// <summary>
        /// 单据属性
        /// </summary>
        public int BillProperty = -1;
        /// <summary>
        /// 记帐
        /// </summary>
        public string TallyId = string.Empty;
        /// <summary>
        /// 已开票本币金额
        /// </summary>
        public decimal InvoiceMoney = 0m;
        /// <summary>
        /// 已开票原币金额
        /// </summary>
        public decimal NInvoiceMoney = 0m;
        /// <summary>
        /// 导入类型(1为普通单据)
        /// </summary>
        public int ImportType = 0;
        /// <summary>
        /// 折扣
        /// </summary>
        public decimal Discount = 1m;
        /// <summary>
        /// 是否参与开票
        /// </summary>
        public int AllowInvoicing = 1;
        /// <summary>
        /// 单据编号生效规则0：保存生效 1：生成生效 2：过账生效
        /// </summary>
        public int billcodecreatetime;
        #endregion

    }
    /// <summary>
    /// 调拨单明细
    /// </summary>
    public class CommoditiesDetail
    {
        /// <summary>
        /// 商品id
        /// </summary>
        public string Pusercode { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public int CQty { get; set; }

        /// <summary>
        /// 序列号
        /// </summary>
        public string Serial { get; set; }
        /// <summary>
        /// 摘要
        /// </summary>
        public string Comment { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public string CPrice { get; set; }
        public string InCargoCode { get; set; } = "";
        public string OutCargoCode { get; set; } = "";
    }
    /// <summary>
    /// 时间段
    /// </summary>
    public class TimeInterval
    {
        public string StartDate { get; set; }
        public string EndDate { get; set; }
    }
    /// <summary>
    /// 出入库汇总
    /// </summary>
    public class InOutstocktableModel
    {
        /// <summary>
        /// 出入库汇总表id
        /// </summary>
        public int ID { get; set; }
        /// <summary>
        /// 汇总表id
        /// </summary>
        public string BillNumberId { get; set; }
        /// <summary>
        /// 序列号
        /// </summary>
        public string Serial { get; set; }
        /// <summary>
        /// 订单号
        /// </summary>
        public string billcode { get; set; }
        /// <summary>
        /// 订单时间
        /// </summary>
        public string posttime { get; set; }
        /// <summary>
        /// 单据类型id
        /// </summary>
        public int BillType { get; set; }
        /// <summary>
        /// 单据类型名称
        /// </summary>
        public string BillName { get; set; }
        /// <summary>
        /// 商品id
        /// </summary>
        public string PtypeId { get; set; }
        /// <summary>
        /// 商品编码
        /// </summary>
        public string PtypeCode { get; set; }
        /// <summary>
        /// 商品名称
        /// </summary>
        public string PtypeName { get; set; }
        /// <summary>
        /// 职员id
        /// </summary>
        public string EtypeId { get; set; }
        /// <summary>
        /// 职员编码
        /// </summary>
        public string EtypeCode { get; set; }
        /// <summary>
        /// 职员名称
        /// </summary>
        public string EtypeName { get; set; }
        /// <summary>
        /// 仓库id
        /// </summary>
        public string KtypeId { get; set; }
        /// <summary>
        /// 仓库编码
        /// </summary>
        public string KCode { get; set; }
        /// <summary>
        /// 仓库名称
        /// </summary>
        public string Kname { get; set; }
        /// <summary>
        /// 数量
        /// </summary>
        public decimal Qty { get; set; }
        /// <summary>
        /// 单价
        /// </summary>
        public decimal Price { get; set; }
        /// <summary>
        /// 金额
        /// </summary>
        public decimal Total { get; set; }
        /// <summary>
        /// 成本单价
        /// </summary>
        public decimal CostPrice { get; set; }
        /// <summary>
        /// 成本金额
        /// </summary>
        public decimal CostTotal { get; set; }
        /// <summary>
        /// 是否赠品 0普通，1赠品
        /// </summary>
        public int IsGift { get; set; }
        /// <summary>
        /// 商品分类
        /// </summary>
        public string Category { get; set; }
        /// <summary>
        /// 客户名称
        /// </summary>
        public string SysDiy1_head { get; set; }
        /// <summary>
        /// 客户电话
        /// </summary>
        public string SysDiy2_head { get; set; }

    }
    /// <summary>
    ///  根据序列号模糊查询库存
    /// </summary>
    public class SerialPtype
    {
        public string Serial { get; set; }
        public int PageIndex { get; set; } = 1;
        public int PageSize { get; set; } = 2000000000;
    }
    /// <summary>
    /// 查询单据状态
    /// </summary>
    public class BillStatus
    {
        public string BillCode { get; set; }
    }
}